package cn.afterturn.svn.analysis.service.repositoryinfo;

import java.util.List;

import org.nutz.dao.Cnd;
import org.nutz.dao.QueryResult;
import org.nutz.dao.pager.Pager;
import org.nutz.dao.sql.Criteria;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.service.IdEntityService;

import cn.afterturn.svn.analysis.entity.repositoryinfo.RepositoryInfoEntity;

/**
 * ���ñ� ����
 * @author JueYue
 * @date 2015-07-29 15:41
 * @version V1.0  
 **/
@IocBean(name = "repositoryInfoService", fields = { "dao" })
public class RepositoryInfoService extends IdEntityService<RepositoryInfoEntity> {

    private static final Log log = Logs.get();

    public QueryResult getRepositoryInfoPage(RepositoryInfoEntity entity, Pager pager) {
        Criteria cri = Cnd.cri();
        if (Strings.isNotBlank(entity.getName())) {
            cri.where().and("name", "=", entity.getName());
        }
        if (Strings.isNotBlank(entity.getUsername())) {
            cri.where().and("user", "=", entity.getUsername());
        }
        List<RepositoryInfoEntity> list = dao().query(RepositoryInfoEntity.class, cri, pager);
        pager.setRecordCount(dao().count(RepositoryInfoEntity.class, cri));
        return new QueryResult(list, pager);
    }

}
